package com.wondertek.web.controller.sys;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wondertek.common.base.Result;
import com.wondertek.service.dto.sys.req.AppVersionAddReq;
import com.wondertek.service.dto.sys.req.AppVersionQueryReq;
import com.wondertek.service.dto.sys.req.AppVersionUpdateReq;
import com.wondertek.service.entity.sys.AppVersionPo;
import com.wondertek.service.service.sys.IAppVersionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * app版本
 */
@RestController
@RequestMapping("/backend/sys/version")
@Tag(name = "app版本管理")
public class AppVersionController {

    @Resource
    private IAppVersionService appVersionService;

    /**
     * app版本新增
     *
     * @param appVersionAddReq
     * @return
     */
    @PostMapping("/add")
    @Operation(summary = "app版本新增")
    public Result<?> add(@RequestBody @Validated AppVersionAddReq appVersionAddReq) {
        appVersionService.add(appVersionAddReq);
        return Result.success();
    }

    /**
     * app版本修改
     *
     * @param appVersionUpdateReq
     * @return
     */
    @PostMapping("/update")
    @Operation(summary = "app版本修改")
    public Result<?> update(@RequestBody @Validated AppVersionUpdateReq appVersionUpdateReq) {
        appVersionService.update(appVersionUpdateReq);
        return Result.success();
    }

    /**
     * app版本分页查询
     *
     * @return
     */
    @PostMapping("/page")
    @Operation(summary = "app版本分页查询")
    public Result<Page<AppVersionPo>> page(@RequestBody AppVersionQueryReq appVersionQueryReq) {
        Page<AppVersionPo> page = appVersionService.page(appVersionQueryReq);
        return Result.success(page);
    }
}
